package cc.codeshop.animator.grid;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import cc.codeshop.animator.R;
import cc.codeshop.animator.helper.DataHelper;
import cc.codeshop.animator.helper.User;

public class GridAdapter extends BaseAdapter {
	
	private Context context;
	private List<User> userList;
	
	public GridAdapter(Context context) {
		this.context  = context;
		this.userList = DataHelper.getUserList();
	}

	@Override
	public int getCount() {
		return userList.size();
	}

	@Override
	public Object getItem(int position) {
		return userList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imgView;
		if(convertView == null) {
			imgView = new ImageView(context);
			imgView.setAdjustViewBounds(true);
			convertView = imgView;;
		} else {
			imgView = (ImageView)convertView;
		}
		imgView.setImageResource(R.drawable.photo_small);
		return convertView;
	}

}
